package com.example.testcodeframe;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.example.data.MainListData;


public class MainActivity extends ListActivity
{

	private MainListData listdata;
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		listdata=new MainListData();
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, listdata.titles);
		
		setListAdapter(adapter);
	}
	
	public void onListItemClick(AdapterView<?> parent, View view, int postion,
			long id)
	{
		Toast.makeText(getApplicationContext(), "1212", Toast.LENGTH_SHORT);
		Intent it=new Intent(MainActivity.this,listdata.classes.get(postion));
		it.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		try
		{
			startActivity(it);
		}
		catch(Exception e)
		{
			Log.e("Exception",e.getMessage());
			e.getStackTrace();
		}

	}

	

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
